package com.jtech.together.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.jtech.together.R;
import com.jtech.together.util.ImageUtils;
import com.jtechlib2.adapter.RecyclerAdapter;
import com.jtechlib2.view.RecyclerHolder;

/**
 * 动态显示图片适配器
 * Created by wuxubaiyang on 2017/5/11.
 */

public class TrendsShowImageAdapter extends RecyclerAdapter<String> {
    private int itemSize;

    public TrendsShowImageAdapter(Context context, int itemSize) {
        super(context);
        this.itemSize = itemSize;
    }

    @Override
    protected View createView(LayoutInflater layoutInflater, ViewGroup viewGroup, int viewType) {
        return layoutInflater.inflate(R.layout.view_trends_show_image, viewGroup, false);
    }

    @Override
    protected void convert(RecyclerHolder holder, String model, int position) {
        //设置item尺寸
        holder.itemView.setLayoutParams(new LinearLayout.LayoutParams(itemSize, itemSize));
        //显示图片
        ImageUtils.showImage(getContext(), model, holder.getImageView(R.id.imageview_trends_show_image));
    }
}